/**
 * @file LightBlob.h
 * @author enemy1205 (enemy1205@qq.com)
 * @brief 灯条类头文件
 * @date 2021-08-16
 */
#pragma once

#include <opencv2/core/mat.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "Math.h"
#include "Parameter.h"
#include "Features.h"

using cv::Point2f;
using cv::Point;
using std::deque;
using std::shared_ptr;

class Light_blob;

using Blob_ptr = std::shared_ptr<Light_blob>;

class Light_blob : public Features {
public:
    //通过旋转矩形构造灯条
    Light_blob(vector<Point> &, cv::RotatedRect &);

    //返回上顶点
    inline Point2f getTpoint() { return this->top_point; }

    //返回下顶点
    inline Point2f getBpoint() { return this->bottom_point; }

    //返回外接矩形，仅供绘图用
    inline auto getRect() { return this->rect; }

    void updateRestInfo() override {};

    Features_ptr getSon1_Features() override { return nullptr; };

    Features_ptr getSon2_Features() override { return nullptr; };

private:
//    float area;//灯条面积
    Point2f top_point;//上顶点
    Point2f bottom_point;//下顶点
//    vector<cv::Point> contours;//点集轮廓
    std::shared_ptr<cv::RotatedRect> rect;//拟合外接旋转矩形,仅供绘图用
    //判断灯条有效性
    void isValidLightblob(vector<Point> &, cv::RotatedRect &);

    //获得准确顶点
    void getTruePoint(vector<Point> &);

};
